package com.ruoyan.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Package: com.ruoyan.config
 * @ClassName: MyWebConfig
 * @Author: ruoyan1998
 * @CreateTime: 2021/6/6 15:44
 * @Description:
 */
@Configuration
public class MyWebConfig implements WebMvcConfigurer
{
    @Override
    public void addViewControllers(ViewControllerRegistry registry)
    {
        registry.addViewController("/dashboard").setViewName("dashboard");
        registry.addViewController("/index").setViewName("index");
    }

    /**
     * 配置登录拦截器*/
    @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/**").excludePathPatterns("/index",
                "/","/user/login","/user/logout","/kaptcha","/css/*","/js/**","/img/*");
    }

    /**
     * 自定义的国际化组件*/
    @Bean
    public LocaleResolver localeResolver()
    {
        return new InterLocaleResolver();
    }

}

